<?php

namespace app\admin\model\choi;

use think\Model;
use traits\model\SoftDelete;

class Message extends Model
{

    use SoftDelete;

    

    // 表名
    protected $table = 'message';
    
    // 自动写入时间戳字段
    protected $autoWriteTimestamp = 'int';

    // 定义时间戳字段名
    protected $createTime = 'createtime';
    protected $updateTime = 'updatetime';
    protected $deleteTime = 'deletetime';

    // 追加属性
    protected $append = [
        'type_name'
    ];

    public function getTypeNameAttr($value, $data)
    {
        $value = '';
        if ($data['type_id']) {
            $typeId = explode(',', $data['type_id']);
            $title = Type::whereIn('id', $typeId)->column('title_zh');
            $value = implode('，', $title);
        }
        return $value;
    }


    







}
